package fire.and.near.challenger.database;

public class ChallengeModel {
	private int ID;
	private String description;
	private String answer;
	private String hashtag;
	private ChallengeType challengeType;
	private String photoPath;
	private FriendModel challenger;
	private long challengedID;
	private boolean accepted = false;
	private ChallengeStatus status = null;

	public ChallengeModel() {
		this.challenger = new FriendModel();
	}

	public ChallengeModel(int id, String description, String answer,
			ChallengeType challengeType, String photoPath, long challengerID,
			long challengedID, boolean accepted, ChallengeStatus status) {
		this.challenger = new FriendModel();
		this.ID = id;
		this.description = description;
		this.answer = answer;
		this.challengeType = challengeType;
		this.photoPath = photoPath;
		this.challenger.setFbID(challengerID);
		this.challengedID = challengedID;
		this.accepted = accepted;
		this.status = status;
	}

	public ChallengeModel(int id, String description, String answer,
			ChallengeType challengeType, String photoPath,
			FriendModel challenger, long challengedID, boolean accepted,
			ChallengeStatus status) {
		this.ID = id;
		this.description = description;
		this.answer = answer;
		this.challengeType = challengeType;
		this.photoPath = photoPath;
		this.challenger = challenger;
		this.challengedID = challengedID;
		this.accepted = accepted;
		this.status = status;
	}

	public int getID() {
		return this.ID;
	}

	public void setID(int id) {
		this.ID = id;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	public String getAnswer() {
		return this.answer;
	}
	
	public void setAnswer(String answer) {
		this.answer = answer;
	}

	public ChallengeType getChallengeType() {
		return challengeType;
	}

	public int getChallengeTypeForDatabase() {
		return this.getChallengeType().asInt();
	}

	public void setChallengeType(ChallengeType challengeType) {
		this.challengeType = challengeType;
	}

	public void setChallengeType(int challengeType) {
		switch (challengeType) {
		case 1:
			this.challengeType = ChallengeType.TEXT;
			break;
		case 2:
			this.challengeType = ChallengeType.PHOTO;
			break;
		}
	}

	public String getPhotoPath() {
		return photoPath;
	}

	public void setPhotoPath(String photoPath) {
		this.photoPath = photoPath;
	}

	public FriendModel getChallenger() {
		return this.challenger;
	}

	public void setChallenger(FriendModel challenger) {
		this.challenger = challenger;
	}

	public void setChallengerID(FriendModel challenger) {
		this.challenger = challenger;
	}

	public long getChallengedID() {
		return challengedID;
	}

	public void setChallengedID(long challengedID) {
		this.challengedID = challengedID;
	}

	public boolean isAccepted() {
		return accepted;
	}

	public void setAccepted(boolean accepted) {
		this.accepted = accepted;
	}

	public String getHashtag() {
		return hashtag;
	}

	public void setHashtag(String hashtag) {
		this.hashtag = hashtag;
	}

	public ChallengeStatus getStatus() {
		return status;
	}

	public void setStatus(ChallengeStatus status) {
		this.status = status;
	}

	public enum ChallengeType {
		TEXT, PHOTO;

		public int asInt() {
			if (this == TEXT) {
				return 1;
			} else {
				return 2;
			}
		}
	}
}
